<%-- 
    Document   : agregarFuncion
    Created on : 22-dic-2011, 22:34:37
    Author     : Administrador
--%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Agregar funcion</title>
    </head>
    <body>
        <jsp:include page="index.jsp" />
        <table border="0">
            <tr height="200">
                <td width="900"></td>
                <td><a href="index.jsp">Ir a pagina principal</a></td>
            </tr>
        </table>
        <form action="agregarFuncion" id="form">
            <jsp:useBean id="pelicula" class="javabeans.JBPelicula" scope="session"/>
            <table>
                <tr>
                    <td width="360"></td>
                    <td width="150"></td>
                    <td width="150"></td>
                </tr>
                <tr>
                    <td></td>
                    <td>Pelicula</td>
                    <td><jsp:getProperty name="pelicula" property="nombre"/></td>
                </tr>
            </table>
            <c:if test="${not empty pelicula.listaFunciones}">
                <table>
                    <tr>
                        <td width="360"></td>
                        <td width="100"></td>
                        <td width="100"></td>
                        <td width="100"></td>
                        <td width="100"></td>
                        <td width="100"></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><b>Cine</b></td>
                        <td><b>Sala</b></td>
                        <td><b>Fecha</b></td>
                        <td><b>Horario</b></td>
                        <td><b>Duracion</b></td>
                    </tr>
                    <c:forEach var="funcion" items="${pelicula.listaFunciones}">
                        <tr>
                            <td></td>
                            <td>${funcion.cine.nombre}</td>
                            <td>${funcion.sala.numero}</td>
                            <td><fmt:formatDate value="${funcion.fecha}" dateStyle="medium" pattern="dd/MM/yyyy"></fmt:formatDate>  </td>
                            <td>${funcion.duracion}</td>
                            <td>${funcion.capacidad}</td>
                        </tr>
                    </c:forEach>
                </table>
            </c:if>
            <table>
                <tr>
                    <td width="360"></td>
                    <td width="150"></td>
                    <td width="400"></td>
                </tr>
                <tr>
                    <td></td>
                    <td>Cines</td>
                    <td>
                        <select id="cbcines" name="cbcines" style="width: 150px; padding: 4px">
                            <c:choose>
                                <c:when test="${not empty sessionScope.cineSeleccionado}">
                                    <option value="${cineSeleccionado.id}">${cineSeleccionado.nombre}</option>
                                </c:when>
                                <c:otherwise>
                                    <option> - Seleccionar - </option>
                                    <c:forEach var="cine" items="${sessionScope.cines}">
                                        <option value="${cine.id}">${cine.nombre}</option>
                                    </c:forEach>
                                </c:otherwise>
                            </c:choose>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>Salas</td>
                    <td>
                        <select name="cbsalas" style="width: 150px; padding: 4px">
                            <c:if test="${empty sessionScope.cineSeleccionado}">
                                <c:remove var="salas" scope="session"/>
                            </c:if>
                            <option> - Seleccionar - </option>
                            <c:forEach var="sala" items="${sessionScope.salas}">
                                <option value="${sala.id}">${sala.numero}</option>
                            </c:forEach>
                            <c:remove var="cineSeleccionado" scope="session"/>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>Fecha</td>
                    <td><input type="text" name="fecha" id="fecha" value="" style="width: 150px; padding: 3px"  class="required date"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td>Horario</td>
                    <td>
                        <table>
                            <td><input type="text" name="hora" style="width: 30px; padding: 2px" maxlength="2" class="required number"/></td>
                            <td>:</td>
                            <td><input type="text" name="minutos" style="width: 30px; padding: 2px" maxlength="2" class="required number"/></td>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>Duracion (min)</td>
                    <td><input type="text" name="duracion" style="width: 30px; padding: 3px" maxlength="3" class="required number" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td>&nbsp
                        <c:if test="${not empty requestScope.error}">
                            <font color="red">${requestScope.error}</font>
                            <c:remove scope="request" var="error" /> 
                        </c:if>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td><input type="submit" value="Agregar" style="width: 150px; padding: 4px"/></td>
                </tr>
            </table>
        </form>
        <script type="text/javascript">
            $(document).ready(function(){
                
                $("#cbcines").change(function(){
                    location.href = "cineSeleccionado?idCine=" + $("#cbcines").val();
                }); 
                
                $("#fecha").datepicker();
            
                $("#form").validate();
            })
        </script>

    </body>
</html>


